<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@page import="com.yaodian100.core.common.utils.ServerValue"%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta http-equiv="Content-Language" content="zh-CN" />
<meta http-equiv="X-UA-Compatible" content="IE=EmulateIE7" />
<link rel="stylesheet" href="/css/yaodian100_v1.css" type="text/css" media="screen" />
<link rel="stylesheet" type="text/css" href="/css/jquery-ui-1.7.2.custom.css">
<script type="text/javascript" charset="UTF-8" src="/js/jquery-1.3.2.min.js"></script>
<script type="text/javascript" charset="UTF-8" src="/js/jquery-ui-1.7.2.custom.min.js"></script>

<script language="javascript">
$().ready( function() {

	$("#dialog").dialog({
		bgiframe: true,
		autoOpen: false,
		height: 150,
		width:350,
		modal: true
	});

	$("#cdialog").dialog({
		bgiframe: true,
		autoOpen: false,
		height: 255,
		width:450,
		modal: true
	});

	var productId = "<%=request.getParameter("productId") %>";
	var price = "<%=request.getParameter("price") %>";
	var categoryId = "<%=request.getParameter("categoryId") %>";

	if(productId!="null"&&price!="null"){
		saveWishProduct(productId,price);
	}else if(categoryId != "null"){
		$("#cdialog").dialog('open');
	}
	
	$(":a[id*=addWishList]").click(function(){
		var pp = $(this).attr('id').split('_');
		productId = pp[1];
		price = pp[2];
		$.post("<%=ServerValue.getFrontContextPath()%>/checkLogin.do",{pathparam:'<%=ServerValue.getFrontHostname()%>'+window.location.pathname+"?productId="+productId+"&price="+price},callback,"json");
		function callback(result){
			if(result=='login'){
				saveWishProduct(productId,price);
			}else{
				window.location.replace("<%=ServerValue.getFrontContextPath()%>/tologin.do?redirect_url="+result); 
			}
		}
	});

	$(":a[id*=addCategoriesList]").click(function(){
		categoryId = $(this).attr('id').split('_')[1];
		$.post("<%=ServerValue.getFrontContextPath()%>/checkLogin.do",{pathparam:'<%=ServerValue.getFrontHostname()%>'+window.location.pathname+"?categoryId="+categoryId},callback,"json");
		function callback(result){
			if(result=='login'){
				$("#cdialog").dialog('open');
			}else{
				window.location.replace("<%=ServerValue.getFrontContextPath()%>/tologin.do?redirect_url="+result); 
			}
		}
	});

	$("#d_ok").click(function(){$("#dialog").dialog('close');});
	$("#cd_ok").click(function(){
		saveWishCategories(categoryId, $("#c_memo").attr('value'));
		$("#cdialog").dialog('close');
	});
	$("#cd_cancel").click(function(){$("#cdialog").dialog('close');});

	function saveWishProduct(productId, productPrice){
		$.post("<%=ServerValue.getFrontContextPath()%>/member/myCollection/saveWishList.do",{productId:productId,productPrice:productPrice},callback,"json");
		function callback(result){
			if(result=='success'){
				$("#result").text('此商品已成功加入收藏！');
			}else{
				$("#result").text('此商品已存在於收藏夹中！');
			}
			$("#tocollection").attr('href',"<%=ServerValue.getFrontContextPath()%>/member/myCollection/toproductc.do");
			$("#dialog").dialog('open');
		}
	}

	function saveWishCategories(categoryId, categoryMemo){
		$.post("<%=ServerValue.getFrontContextPath()%>/member/myCollection/saveWishList.do",{categoryId:categoryId, categoryMemo:categoryMemo},callback,"json");
		function callback(result){
			if(result=='success'){
				$("#result").text('此分类已成功加入收藏');				
			}else{
				$("#result").text('此分类已存在於收藏夹中！');
			}
			$("#tocollection").attr('href',"<%=ServerValue.getFrontContextPath()%>/member/myCollection/tocategoriesc.do");
			$("#dialog").dialog('open');
		}
	}
	
});
</script>
</head>
<body>
<DIV id="dialog" title="收藏商品" class="collection-dailog-ok">        
<p id="result">此商品已成功加入收藏！</p>
<div align="center">
<span style="text-align:center;"><a href="<%=ServerValue.getFrontContextPath()%>/member/myCollection/toproductc.do" class="btn-mid" id="tocollection">查看收藏夹</a></span>
<span style="text-align:center;"><a href="javascript:;" id="d_ok" class="btn-mid">确定</a></span>
</div>
</DIV>
<DIV id="cdialog" title="收藏分类" class="collection-dailog">
		 
          <div class="collection-dailog">
          <p>将感兴趣的类别加入收藏，系统会将分类路径储存在「收藏夹」中，方便你下次迅速找查。</p>
          <ul>
          <li class="w-a"><strong>分 类：</strong>鞋包配饰 > 流行女鞋 > 人气女鞋天后 > wink X</li>

          <li class="w-b"><div class="f-lt"><strong>备 注：</strong><br /><span class="t-note">非必填</span></div>
          <div class="t-area"><textarea cols="50" rows="3" class="txt-gy" id="c_memo">(您可以输入简单的备注，最多50个字。)</textarea></div>
          </li>
          </ul>
         </div>

         <div align="center">
 		 <span style="text-align:center;"><a href="#" class="btn-mid" id="cd_ok">确定加入</a></span>

         <span style="text-align:center;"><a href="#" class="btn-mid" id="cd_cancel">取消</a></span>
         </div>

</DIV> 
<a href="javascript:;" id="addWishList_00000004_300">加入收藏4</a>&nbsp;&nbsp;
<a href="javascript:;" id="addWishList_00000005_200">加入收藏5</a>&nbsp;&nbsp;
<a href="javascript:;" id="addWishList_00000006_199">加入收藏6</a>&nbsp;&nbsp;
<a href="javascript:;" id="addWishList_00000007_250">加入收藏7</a>&nbsp;&nbsp;
<a href="javascript:;" id="addWishList_00000008_99">加入收藏8</a><br>
<a href="javascript:;" id="addWishList_00000009_120">加入收藏9</a>&nbsp;&nbsp;
<a href="javascript:;" id="addWishList_00000010_50">加入收藏10</a>&nbsp;&nbsp;
<a href="javascript:;" id="addWishList_00000011_120">加入收藏11</a>&nbsp;&nbsp;
<a href="javascript:;" id="addWishList_00000012_350">加入收藏12</a>&nbsp;&nbsp;
<a href="javascript:;" id="addWishList_00000013_400">加入收藏13</a><br>
<a href="javascript:;" id="addWishList_00000399_1000">加入收藏00000399</a>&nbsp;&nbsp;
<br><br>

<a href="javascript:;" id="addCategoriesList_13">收藏類別13</a>&nbsp;&nbsp;
<a href="javascript:;" id="addCategoriesList_41">收藏類別41</a>&nbsp;&nbsp;
<a href="javascript:;" id="addCategoriesList_42">收藏類別42</a>&nbsp;&nbsp;
<a href="javascript:;" id="addCategoriesList_43">收藏類別43</a>&nbsp;&nbsp;
<a href="javascript:;" id="addCategoriesList_44">收藏類別44</a>&nbsp;&nbsp;
<a href="javascript:;" id="addCategoriesList_45">收藏類別45</a>&nbsp;&nbsp;
<a href="javascript:;" id="addCategoriesList_46">收藏類別46</a>

</body>
</html>